package uy.com.tsi2G7.superbet.user;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Table(name="USERS")
@Entity
public class User implements Serializable{
	private static final long serialVersionUID = 1L;
	@Column(name="NAME",length=255)
	private String name;
	@Column(name="SURNAME",length=255)
	private String surname;
	@Id 
	@Column(name="MAIL",length=255)
	private String mail;
	@Column(name="SEX",length=1)
	private String sex;
	@Column(name="COUNTRY",length=3)
	private String country;
	@Column(name="CITY")
	private int city;
	@Column(name="BORNDAY")
	private Timestamp bornDay;
	@Column(name="PASSWORD")
	private String password;
	@ManyToMany(fetch= FetchType.EAGER)
    @JoinTable(name="users_roles")
    @Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
    private Set<Role> roles;
	
	public User(){	
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public int getCity() {
		return city;
	}

	public void setCity(int city) {
		this.city = city;
	}

	public Timestamp getBornDay() {
		return bornDay;
	}

	public void setBornDay(Timestamp bornDay) {
		this.bornDay = bornDay;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

}
